home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / Comms1.pxl < prev    next >
Text File  |  1998-02-18  |  5KB  |  189 lines

  1. Initialize:
  2.     Title1$ = "Message Passing App #1"
  3.     Title2$ = "Message Passing App #2"
  4.     UseCaption(Title1$)
  5.     UseCoordinates(PIXEL)
  6.     UseBackGround(TRANSPARENT,192,192,192)
  7.     DrawBackGround
  8.     WinLocate(Title1$,250,10,680,240,Res) 
  9.     { WinShow(Title1$,NOTOPMOST,Res) }
  10.     DirGet(SourceDir$)
  11.     WinGetClientRect("",cx1,cy1,cx2,cy2)
  12.  
  13.     InfoMenu(REMOVE)
  14.     WaitInput(100)  {let NT and 95 catch up}
  15.     SetMenu("E&xit!",Leave,
  16.         ENDPOPUP,
  17.         "&Mode",IGNORE,
  18.         "Set &Transmit Mode",Transmit,
  19.         "Set &Receive Mode",Receive,
  20.         "&Loop",CommLoop,
  21.         SEPARATOR,
  22.         "Jump to Label",JumpLabel,
  23.         "Copy Data",CopyDataJump,
  24.         "Clear",Clear,
  25.         "Clear Both",ClearBoth,
  26.         ENDPOPUP,
  27.         "&Help",IGNORE,
  28.         "&Concept",Concept,
  29.         "&View Source",ViewSource,
  30.         "&About",About,
  31.         ENDPOPUP)
  32.         
  33.     StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
  34.     DrawStatusWinText(0,"Ready")
  35.  
  36.         Loop = 0        
  37.  
  38. Wait_for_Input:
  39.     WaitInput()
  40.  
  41. { NOTE: if a PXLResume message is received while the 
  42.   program is pausing at the above WaitInput(), it will
  43.  proceed directly to the next command, and then in this 
  44. case, exit.
  45.  
  46.  You may want to program a simple solution around this, 
  47.  such as ... 
  48.  
  49.     Goto Wait_for_Input
  50.  
  51. or instead use the PXLResumeAt(...) command.  }
  52.  
  53. Leave:
  54.     WinClose(Title2$,Res)
  55.     End
  56.  
  57. Clear:
  58.     SetRightMouse()
  59.     SetMouse()
  60.     Loop = 0
  61.     DrawBackground
  62.     DrawStatusWinText(0,"Ready")
  63.     DrawStatusWinText(1,"")
  64.     Goto Wait_for_Input
  65.  
  66. ClearBoth:
  67.     SetRightMouse()
  68.     SetMouse()
  69.     Loop = 0
  70.     DrawBackground
  71.     DrawStatusWinText(0,"Ready")
  72.     DrawStatusWinText(1,"")
  73.     PXLresumeAt(Title2$,"Clear",Title1$,Res)
  74.     Goto Wait_for_Input
  75.  
  76. CopyDataJump:
  77.     Msg$ = "ReceiveCopyData Arbitary message from #1"
  78.     SendCopyDataMsg(Title2$,Msg$)
  79.     Goto Wait_for_Input
  80.  
  81. ReceiveCopyData:
  82.     GetCopyDataMsg(Msg$)
  83.     DrawText(10,70,Msg$)
  84.     Goto Wait_for_Input
  85.  
  86.  
  87. JumpLabel:
  88.     PXLresumeAt(Title2$,"JumpLabel_2",Title1$,Res)
  89.     WaitInput(1)
  90.  
  91.     {NOTE: in THIS SPECIFIC case, the WaitInput(1) is needed because the
  92.        application will overwrite the jump_label string. ie you must give the 
  93.      target application time to process the command. You could also put 
  94.      in a WaitInput() here and have the target application send a PXLresume}
  95.  
  96.     PXLresumeAt(Title2$,"JumpLabel_2a",Title1$,Res)
  97.     WaitInput(1)
  98.     PXLresumeAt(Title2$,"JumpLabel_2b",Title1$,Res)
  99.  
  100.     If Res = 0 Then MessageBox(OK,1,INFORMATION,"Resume in #2 failed","DEBUG",Res)
  101.     Goto Wait_for_Input
  102.  
  103. JumpLabel_1:
  104.     DrawBackground
  105.     DrawText(10,10,"Processed resume at JumpLabel_1 Message")
  106.     Goto Wait_for_Input
  107.  
  108. JumpLabel_1a:
  109.     DrawText(10,30,"Processed resume at JumpLabel_1a Message")
  110.     Goto Wait_for_Input
  111.  
  112. JumpLabel_1b:
  113.     DrawText(10,50,"Processed resume at JumpLabel_1b Message")
  114.     Goto Wait_for_Input
  115.  
  116.  
  117. CommLoop:
  118.     Loop = 1    
  119.     DrawStatusWinText(1,"Loop Enabled")
  120.     Goto Wait_for_Input
  121.  
  122.  
  123. Transmit:
  124.     SetRightMouse(cx1,cy1,cx2,cy2,StopProcess,X,Y)
  125.     SetMouse(cx1,cy1,cx2,cy2,Process,X,Y)
  126.     DrawStatusWinText(0,"Transmit Enabled")
  127.     If Loop = 0 Then Goto Wait_for_Input
  128.  
  129. Receive:
  130.     WaitInput()   {This is the WaitInput that the loop mode cycles around}
  131.     DrawBackGround
  132.     DrawIcon(10,10,64,64,ICON02)
  133.     WaitInput(1)
  134.     If Loop = 0 Then Goto Wait_for_Input
  135. Process:
  136.     SetMouse()
  137.     PXLResume(Title2$,Res)
  138.     WaitInput(1)
  139.     If Res = 0 Then MessageBox(OK,1,INFORMATION,"Msg Failed",Title1$,Res)
  140.     If Loop = 1 Then Goto Receive
  141.     Goto Wait_for_Input
  142.  
  143. StopProcess:
  144.     Loop = 0
  145.     SetRightMouse()
  146.     DrawStatusWinText(0,"Ready")
  147.     Goto Receive {or the last 'resume' from #2 will hit Wait_for_Input then exit.}
  148.  
  149. Concept:
  150.     Loop = 0
  151.     SetMouse()
  152.     SetRightMouse()
  153.     DrawStatusWinText(0,"Ready")
  154.     MessageBox(OK,1,INFORMATION,
  155. "This sample program demonstrates how two PiXCL
  156. applications can communicate with each other by
  157. passing a 'resume' message after a WaitInput()
  158. command has been issued.
  159.  
  160. You can select transmit or receive ONE message at a time,
  161. or select LOOP, then receive or transmit, and the two
  162. programs will alternate sending 'resume' messages to
  163. each other.
  164.  
  165. Once you have set up the transmit and receive modes,
  166. click in the transmit window client area to start.
  167.  
  168. You can also send arbitary length messages to the 
  169. other window.
  170.  
  171. Clicking 'Exit' will close both message apps.",
  172.     "Message Passing",Res)
  173.     Goto Wait_for_Input
  174.  
  175. ViewSource:
  176.     PXLFile$ = SourceDir$ + "\comms1.pxl"
  177.     CmdLine$ = "NotePad " + PXLFile$
  178.     Run(CmdLine$)
  179.     Goto Wait_for_Input
  180.  
  181.  
  182. About:
  183.     AboutUser("Message Passing with PiXCL 4.1",
  184. "WaitInput(), PXLResume and PXLResumeAt commands.", 
  185. "A PXL application can wait for another application to tell it to continue at the current point or any label.")
  186.     Goto Wait_for_Input
  187.  
  188.  
  189.